package com.example.HW;

import java.util.Collections;
import java.util.List;

import org.junit.*;
import static org.junit.Assert.*;
import com.example.pages.UserManagementPage;

public class CreateNewUser extends TestBase {
	
	@Test    
	public void testCreateNewUser() {
		
		UserManagementPage UserPage = goToMainPage()
			.loginWithValidCredentials("admin","admin")		
			.goToUserManagement();
		
		List<User> oldUserList = UserPage.getUsers();
		
		User user = new User()
			.withName("aaaa").withEmail("aaaa@gmail.com").withPassword("aaaa");
		
		UserPage.createUser(user);
		
		List<User> newUserList = UserPage.getUsers();
		
		oldUserList.add(user);
		Collections.sort(oldUserList);
		assertEquals(oldUserList, newUserList);
		
	}
	
}

